//
//  ViewController.m
//  02 -- 图片浏览器
//
//  Created by Rainy Zou on 15/11/16.
//  Copyright © 2015年 Rainy Zou. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
{
    NSArray *_array;
    BOOL flag ;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //应该从系统的安装目录下读取文件
    //NSString *path = [NSString stringWithFormat:@"descs.plist"];
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"descs" ofType:@"plist"];
    
    _array = [NSArray arrayWithContentsOfFile:path ];
    self.imageDesc.text = [_array objectAtIndex:0];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)valueChange:(UISlider *)sender {
    
    // 1 设置中间的图片
    //获取图片的名称 %.f
    
    int seqn = (int) sender.value;
    
    NSString *imageName = [NSString stringWithFormat:@"%d.png",seqn];
    _image.image = [UIImage imageNamed:imageName];
    
    [self.imageNo setText:[NSString stringWithFormat:@"%d/16",(seqn+1)]];
    
    
    
    self.imageDesc.text = [_array objectAtIndex:seqn];
    
}

- (IBAction)setting:(id)sender {
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    flag = !flag;
    CGRect temp =  self.settingView.frame;
    switch (flag) {
        case TRUE:
            temp.origin.y = 380;
            break;
        case FALSE:
            temp.origin.y = 480;
            break;
        default:
            break;
    }
    self.settingView.frame =temp;
    [UIView commitAnimations];
}

- (IBAction)model:(UISwitch *)sender {
    if(sender.on){
        self.view.backgroundColor = [UIColor darkGrayColor];
    }else{
        self.view.backgroundColor = [UIColor whiteColor];
    }
}

- (IBAction)scale:(UISlider *)sender {
    
    self.image.transform =CGAffineTransformMakeScale(sender.value, sender.value);
    
}
@end
